<?php namespace testsacvoyage\domain;

require_once 'sacvoyage/Object.php';
use \sacvoyage\Object;

require_once 'sacvoyage/domain/Property.php';
use \sacvoyage\domain\Property;

require_once 'sacvoyage/domain/Domain.php';
use \sacvoyage\domain\Domain;

require_once 'sacvoyage/domain/User.php';
use \sacvoyage\domain\User;

require_once 'sacvoyage/storage/Database.php';
use \sacvoyage\storage\Database;


require_once 'AbstractTest.php';

class PropertyTest extends AbstractTest {
	
	public function setUp() {
		$this->resetDatabase();
		
		$this->_property=new Property(
			new User(
				new Domain($this->getStorage()),
				'alex',
				new Database($this->getGateway(), 'alex')			
			),
			$this->getStorage()->getDatabase('alex')
		);
	}
	
	public function testWriteRead() {
		$c=$this->_property->getCollection('cfg.notes');
		$c->write(array(new Object(array('_id'=>'newnote', 'text'=>'note text'))));
		$doc=$c->read('newnote');
		$this->assertEquals('note text', $doc->text);
	}
	
	
	
	
	
}



?>